/**
 * Created with JetBrains PhpStorm.
 * User: sergey.uchvatov
 * Date: 08.11.12
 * Time: 14:47
 * To change this template use File | Settings | File Templates.
 */

(function ($) {
    Drupal.behaviors.lonex_category = {
        attach: function (context, settings) {

            //var small = '';

            $(document).ready(function() {
                updateZoom();

            });

            function updateZoom() {
                var large = $('a.large img').attr('src');
                $('a.large').attr('href',large);
            }


            $('#category_slider ul li').hover(
                function() {
                    $("img", $(this)).stop().animate({width:"135px"}, "fast");
//                $(this).stop().animate({width:"125px",height:"125px",left:"-25px",top:"-25px"}, 400);
                },
                function(){
                    $("img", $(this)).stop().animate({width:"112px"}, "fast");
//                    $(this).attr("src","pic1.png");
                }
            );

            $('ul.top-slider li').click(function() {
                var link = $("a" ,$(this)).attr('href');
                location.href = link;
            });


            $('a.thumbnail.small').click(function() {

                var small = $('img', $(this)).attr('src');

                $('a.large img').fadeOut('fast',function() {
                    $(this).attr('src',small);
                    $(this).fadeIn('fast');
                    updateZoom();
                });


                return false;
            });

//********************************************************************

            $('a.prev').one('click', function() {
                var prev = $('.models a.active').attr('prev');

                if(prev > 0) {
                    $('.models li a.model-' + prev).click();
                }
                updateZoom();
                return false;
            });

            $('a.next').one('click', function() {

                var next = $('.models a.active').attr('next');

                if(next > 0) {
                    $('.models li a.model-' + next).click();
                }
                updateZoom();
                return false;
            });

        }

    }
})(jQuery);

